package routers

import (
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"rbac/handlers"
)

func Init() *gin.Engine {

	r := gin.Default()

	//设置跨域
	r.Use(cors.Default())
	//设置静态文件的目录
	r.Static("static", "./static")

	//设置路由
	r.GET("/test/", handlers.Test)

	r.POST("/user/login", handlers.UserLogin)         //用户登录
	r.POST("/user/roleAddNode", handlers.RoleAddNode) //角色分配权限
	r.GET("/user/userRole", handlers.UserRole)        //用户角色信息
	r.GET("/user/roleNode", handlers.RoleNode)        //角色权限信息
	r.POST("/car/add", handlers.Add)                  //汽车添加
	r.POST("/car/orderAdd", handlers.OrderAdd)        //送货订单添加
	r.GET("/car/orderList", handlers.OrderList)       //订单列表
	r.GET("/car/orderDetail", handlers.OrderDetail)   //订单详情

	return r

}
